package cn.com.pc.content.dto;

import lombok.Data;
import lombok.ToString;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.data.domain.Sort.Direction;

/**
 * 排序方式，可组合实现多级排序
 */
@Data
@ToString
public class Sort {

    /**
     * 排序列
     */
    private String sortBy;

    /**
     * 是否升序
     */
    private Boolean asc = true;


    public Direction getDirection() {
        if (this.getAsc()) {
            return Direction.ASC;
        } else {
            return Direction.DESC;
        }
    }

    public SortOrder getSortOrder() {
        if (this.getAsc()) {
            return SortOrder.ASC;
        } else {
            return SortOrder.DESC;
        }
    }
}
